<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>自定义窗体</title>
    <link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script src="//cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="http://webapi.amap.com/maps?v=1.3&key=78d2c8a55b62cb049653ace920a563dc"></script>
    <!-- 下一行是左边的放大缩小移动操作台 -->
<!--    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>-->
</head>
<style>
    #up-map-div{
        width:300px;
        height:300px;
        top:100px;
        left:0px;
        position:absolute;
        z-index:9999;
        border:1px solid blue;
        background-color:#FFFFFF;
    }
</style>
<body>
<div id="container"></div>
<div id="up-map-div" style="background-color: #0c0c0c">
<!--                <table border="1">-->
<!--                    <thead style="background-color: #0b6bbd" ><tr style="color: white"><th>编号</th><th>区流向</th><th>客流量</th></tr></thead>-->
<!--                    <tbody>-->
<!--&lt;!&ndash;                    <tr><td><img src="img/my.jpg"> </td><td>美女</td><td>女</td><td>89%</td></tr>&ndash;&gt;-->
<!--                    <tr style="color: white"><td>B101</td><td>郫都区->双流区</td><td style="color: #ff2222">等待处理</td></tr>-->
<!--                    <tr><td>C107</td><td>犀浦站</td><td>正在处理</td></tr>-->
<!--                    <tr><td>A121</td><td>电子科大站</td><td>正在处理</td></tr>-->
<!--                    <tr><td>A143</td><td>龙泉驿站</td><td style="color: #00a65a">处理成功</td></tr>-->
<!--                    <tr><td>A123</td><td>黄石公园站</td><td style="color: #00a65a">处理成功</td></tr>-->
<!--                    <tr><td>C056</td><td>天府广场站</td><td style="color: #ff2222">等待处理</td></tr>-->
<!--                    <tr><td>C012</td><td>成都东站</td><td style="color: #ff2222">等待处理</td></tr>-->
<!--                    <tr><td>B016</td><td>成都北站</td><td style="color: #00a65a">处理成功</td></tr>-->
<!--                    </tbody>-->
<!--                </table>-->
</div>
<script type="text/javascript">
    //初始化地图对象，加载地图
    var map = new AMap.Map("container", {resizeEnable: true,
        mapStyle: 'amap://styles/1cb196e91d9c8143886b9d2c68eff8d0',
        center: [104.089081,30.309752],
        zoom: 14,
        dragEnable: true
    });
    var lnglats = [
        [104.089081,30.309752],
        [104.086695,30.717551],
        [104.083519,30.704231],
        [104.07084,30.492309],
    ];

    var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
    for (var i = 0, marker; i < lnglats.length; i++) {
        var marker = new AMap.Marker({
            position: lnglats[i],
            map: map
        });
        // marker.content = '<h3>我是第' + (i + 1) + '个XXX</h3>';
        marker.content += '<div>经度：'+lnglats[i][0]+'</div>';
        marker.content += '<div>纬度：'+lnglats[i][1]+'</div>';
        marker.content += '<div><button  class="btn btn-suucess btn-xs">历史轨迹</button>';
        marker.content += '&nbsp;<button class="btn btn-warning btn-xs">实时跟踪&nbsp;</button>';
        marker.content += '&nbsp;<button  class="btn btn-danger btn-xs">设置</button></div>';

        marker.on('mouseover', infoOpen);
        //注释后打开地图时默认关闭信息窗体
        // marker.emit('mouseover', {target: marker});
        marker.on('mouseout', infoClose);
        marker.on('click', newMAp);
    }

    //鼠标点击事件,设置地图中心点及放大显示级别
    function newMAp(e) {
        //map.setCenter(e.target.getPosition());
        map.setZoomAndCenter(15, e.target.getPosition());

        var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());
    }
    function infoClose(e) {
        infoWindow.close(map, e.target.getPosition());
    }
    function infoOpen(e) {
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());
    }
    map.setFitView();

</script>
</body>
</html>
 